<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../layout/main.jsp" %>
<script type="text/javascript" src="js/swfupload/jquery.swfupload.js"/></script>
<script type="text/javascript" src="js/swfupload/swfupload.js"/></script>
 <div id="wrapper">
  <div id="page-wrapper-inner" class="gray-bg dashbard-1">

 <div class="row wrapper  white-bg page-heading">
        <!-- <div class="wrapper wrapper-content animated fadeInRight"> -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>编辑语音</h5>
                        </div>
                        <div class="ibox-content">
                       <f:form action="media/${media.id}" modelAttribute="media" method="post" id="editForm" cssClass="form-horizontal">
                            <input type="hidden" name="_method" value="put"/>
                             <div class="form-group form-inline">
                                 <label class="form-label control-label">名称：</label>
                                 <f:input path="name" cssClass="form-control form-control-60"/>
                                 <em class="required_field">*</em>
                                 <f:errors path="name" cssClass="error-msg"></f:errors>
                             </div>
                              <div class="form-group form-inline">
                                <label class="form-label control-label">类型：</label>
                                <f:select path="category" cssClass="form-control form-control-60">
                                    <f:option value="">请选择</f:option>
                                    <f:option value="welcome"></f:option>
                                    <f:option value="quque">排队</f:option>
                                    <f:option value="error">错误异常</f:option>
                                    <f:option value="other">其它</f:option>
                                </f:select>
                                 <em class="required_field">*</em>
                                 <f:errors path="category" cssClass="error-msg"></f:errors>
                            </div>  
                           <div class="form-group from-inline">
                                    <label class="form-label control-label">附件名称：</label>
                                            <input type="button" id="upload_button"/>
                                            <span data-func="upload-process"></span>
                                            <f:hidden path="fileName" data-name="ivr-filePath" value="" id="filePath"/>
                                           <!--  <a href="javascript:;" class="fa fa-play-circle-o" data-func="playMp3"></a> -->
                                            <f:errors path="fileName" cssClass="error-msg"></f:errors>
                                            
                                            <div id="swfupload-control">
                                            <ul id="attachment" style="display:none;">
                                            </ul>
                                        </div>
                                        </div>
                               <div class="form-group">
                                    <div class="col-sm-4 form-btn-area">
                                      <a  href="javascript:submitForm();" class="btn btn-primary" role="button">保存</a>
                                        <a  href="<c:url value="/media"/>" class="btn btn-info" role="button">取消</a>
                                    </div>
                                </div>
                       </f:form>
                    
                        </div>
                    </div>
                </div>
            </div>
        </div>
   <script type="text/javascript">
   
   function submitForm(){ 
       $('#editForm').submit();
   }
   
   $(document).ready(function(){
       var processBar = $('[data-func="upload-process"]');
       var filePath = $('[data-name="ivr-filePath"]');
     
       $('#swfupload-control').swfupload({
           upload_url:"<%=basePath%>media/upload",
           file_post_name: "uploadFile",
           file_size_limit: "51200",
           file_types: "*.wav",
           file_types_description: "IVRMedia",
           file_upload_limit: 10,
           flash_url: "js/swfupload/swfupload.swf",
           button_image_url: "<%=basePath%>js/swfupload/XPButtonUploadText_61x22.png",
           button_width:64,
           button_height:22,
           button_placeholder:$('#upload_button')[0],
           debug:false
       })
       .bind('fileQueued', function(event, file){
               processBar.text("开始上传...");
               $(this).swfupload('startUpload');
           })
           .bind('fileQueueError', function(event, file, errorCode, message){
               processBar.css({color:'red'}).text("上传失败:"+message);
           })
           .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
           })
           .bind('uploadSuccess', function(event, file, serverData){
               var _json =JSON.parse(serverData);
               filePath.val(_json.fileName);
               processBar.css({color:'green'}).text(file.name+"上传成功");
           })
           .bind('uploadComplete', function(event, file){
               $(this).swfupload('startUpload');
           });

   });
   
   </script>
        
 </div>
 </div>